import BaseController from '../../core/controllers/Base.controller';

@Inject('$log', 'trainingService', '$stateParams', 'ngDialogService')
class educationTrainingDetailController extends BaseController {
  constructor() {
    super();

    this.data = {
      activity: null,
    };

    this.getDetail($stateParams.id);
  }

  getDetail(id) {
    this.trainingService.get(id)
      .then((res) => {
        if (res.success) {
          this.data.activity = res.data;
          if (res.data.departmentBean) {
            const departNames = res.data.departmentBean.map(item => item.name);
            this.data.activity.joinDepartment = departNames.join(',');
          }
        } else {
          this.ngDialogService.alertError(res.message);
        }
      });
  }
}

export default educationTrainingDetailController;
